In [13]:
import numpy as np
import matplotlib.pyplot as plt



from __future__ import print_function
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets

In [31]:
def f(x):
    print("%s! = %s" % (x, np.math.factorial(x)))

In [38]:
interact(f, x=(0, 100))


50! = 30414093201713378043612608166064768844377641568960512000000000000
Out[38]:
<function __main__.f>

In [19]:
def plt_array(x, y, title="", color="red", linestyle="dashed"):
    fig = plt.figure() #maybe make this higher res
    axes = fig.add_subplot(111) # this makes each of our axis praportinal to eachother sense they are 111
    axes.plot(x, y, color=color, linestyle=linestyle)
    axes.set_title(title)
    axes.grid()
    plt.show()

In [22]:
plt_array([1,2], [1,5])


$f(x) = ax^3 + bx^2 + cx + d$


In [23]:
def f(a, b, c, d, **kwargs):
    x = np.linspace(-10,10, 20)
    y = a*(x**3) + b*(x**2) + c*x +d
    
    title = "$f(x) = (%s)x^{3} + (%s)x^{2} + (%s)x + (%s)$" %(a,b,c,d)
    
    plt_array(x,y, title=title, **kwargs)

In [24]:
f(3, 4, 2, 1)



In [27]:
i = interact(f, 
             a=(-10., 10), 
             b=(-10., 10), 
             c=(-50., 50), 
             d=(-10, 10), 
             color = ["red", "green", "blue", "black"],
            linestyle=["solid", "dashed"]
            )



In [ ]: